<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
            border: none;
        }
        img{
            vertical-align: top;
            width: 100%;
        }
        section{
            width: 70%;
            margin: 0 auto;
        }
        .nav{
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
        }
    </style>
    <script src="js/myFunc.js"></script>
</head>
<body>
<header id="head">
    <img src="images/top.png" alt="">
</header>
<nav id="nav">
    <img src="images/nav.png" alt="">
</nav>
<section>
    <img src="images/body01.png" alt="">
    <img src="images/body02.png" alt="">
</section>
<script>
    window.onload=function () {
        var nav_top_height = document.getElementById("nav").offsetHeight;
        window.onscroll=function () {
            var scroll_top_height = scroll().top;
            if(nav_top_height<=scroll_top_height){
                document.getElementById("nav").className="nav"
            }else{
                document.getElementById("nav").className=""
            }
        }
    }
</script>
</body>
</html>